<html>
  <head>
    <meta charset="utf-8">
    <script type="text/javascript" src="blockly_compressed.js"></script>
    <script type="text/javascript" src="blocks_compressed.js"></script>
    <script type="text/javascript" src="en.js"></script>
    <script type="text/javascript" src="ru.js"></script>
    <script type="text/javascript" src="de.js"></script>
    <script type="text/javascript" src="javascript_compressed.js"></script>
    <script type="text/javascript" src="blockly_espruino.js"></script>
    <script type="text/javascript" src="blockly_menu.js"></script>
    <script type="text/javascript" src="blockly_gfx.js"></script>
    <script type="text/javascript" src="blockly_robot.js"></script>
    <script type="text/javascript" src="blockly_amperka_motorshield.js"></script>
    <script type="text/javascript" src="blockly_ble.js"></script>
    <script type="text/javascript" src="blockly_nordic_thingy.js"></script>
    <script type="text/javascript" src="blockly_smartibot.js"></script>
    <script type="text/javascript" src="blockly_bangle.js"></script>
    <script type="text/javascript" src="field_textarea.js"></script>
    <script type="text/javascript" src="../js/libs/imageconverter.js"></script>
    <style>
      html, body {
        background-color: #fff;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }
      .blocklySvg {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>

  <!-- Blockly toolbox -->
  <xml id="toolbox" style="display: none">
    <category name="Logic" colour="%{BKY_LOGIC_HUE}">
      <block type="controls_if"></block>
      <block type="logic_compare"></block>
      <block type="logic_operation"></block>
      <block type="logic_negate"></block>
      <block type="logic_boolean"></block>
      <block type="logic_ternary"></block>
    </category>
    <category name="Control" colour="%{BKY_LOOPS_HUE}">
      <block type="espruino_delay">
        <value name="SECONDS"><block type="math_number"><title name="NUM">1</title></block></value>
      </block>
      <block type="espruino_timeout">
        <value name="SECONDS"><block type="math_number"><title name="NUM">1</title></block></value>
      </block>
      <block type="espruino_interval">
        <value name="SECONDS"><block type="math_number"><title name="NUM">1</title></block></value>
      </block>
      <block type="controls_repeat_ext">
        <value name="TIMES">
          <block type="math_number">
            <title name="NUM">10</title>
          </block>
        </value>
      </block>
      <block type="controls_whileUntil"></block>
      <block type="controls_for">
        <value name="FROM">
          <block type="math_number">
            <title name="NUM">1</title>
          </block>
        </value>
        <value name="TO">
          <block type="math_number">
            <title name="NUM">10</title>
          </block>
        </value>
        <value name="BY">
          <block type="math_number">
            <title name="NUM">1</title>
          </block>
        </value>
      </block>
      <block type="controls_forEach"></block>
      <block type="controls_flow_statements"></block>
    </category>
    <category name="Math" colour="%{BKY_MATH_HUE}">
      <block type="math_number">
        <title name="NUM">0</title>
      </block>
      <block type="math_arithmetic">
        <title name="OP">ADD</title>
      </block>
      <block type="math_single">
        <title name="OP">ROOT</title>
      </block>
      <block type="math_trig">
        <title name="OP">SIN</title>
      </block>
      <block type="math_constant">
        <title name="CONSTANT">PI</title>
      </block>
      <block type="math_number_property">
        <mutation divisor_input="false"></mutation>
        <title name="PROPERTY">EVEN</title>
      </block>
      <block type="math_change">
        <title name="VAR">item</title>
        <value name="DELTA">
          <block type="math_number">
            <title name="NUM">1</title>
          </block>
        </value>
      </block>
      <block type="math_round">
        <title name="OP">ROUND</title>
      </block>
      <block type="math_on_list">
        <title name="OP">SUM</title>
      </block>
      <block type="math_modulo"></block>
      <block type="math_constrain" >
        <value name="LOW">
          <block type="math_number">
            <title name="NUM">1</title>
          </block>
        </value>
        <value name="HIGH">
          <block type="math_number">
            <title name="NUM">100</title>
          </block>
        </value>
      </block>
      <block type="math_random_int">
        <value name="FROM">
          <block type="math_number">
            <title name="NUM">1</title>
          </block>
        </value>
        <value name="TO">
          <block type="math_number">
            <title name="NUM">100</title>
          </block>
        </value>
      </block>
      <block type="math_random_float"></block>
    </category>
    <category name="Text" colour="%{BKY_TEXTS_HUE}">
      <block type="text"  >
        <title name="TEXT"></title>
      </block>
      <block type="text_join" inline="false"  >
        <mutation items="2"></mutation>
      </block>
      <block type="text_append" inline="false"  >
        <title name="VAR">item</title>
        <value name="TEXT">
          <block type="text">
            <title name="TEXT"></title>
          </block>
        </value>
      </block>
      <block type="text_length" inline="false"  ></block>
      <block type="text_isEmpty" inline="true"  ></block>
      <block type="text_indexOf" inline="true"  >
        <title name="END">FIRST</title>
        <value name="VALUE">
          <block type="variables_get">
            <title name="VAR">text</title>
          </block>
        </value>
      </block>
      <block type="text_charAt" inline="true"  >
        <mutation at="true"></mutation>
        <title name="WHERE">FROM_START</title>
        <value name="VALUE">
          <block type="variables_get">
            <title name="VAR">text</title>
          </block>
        </value>
      </block>
      <block type="text_getSubstring" inline="true"  >
        <mutation at1="true" at2="true"></mutation>
        <title name="WHERE1">FROM_START</title>
        <title name="WHERE2">FROM_START</title>
        <value name="STRING">
          <block type="variables_get">
            <title name="VAR">text</title>
          </block>
        </value>
      </block>
      <block type="text_changeCase" inline="false"  >
        <title name="CASE">UPPERCASE</title>
      </block>
      <block type="text_trim" inline="false">
        <title name="MODE">BOTH</title>
      </block>
      <block type="text_print" inline="false">
        <value name="TEXT"><block type="text"><title name="TEXT">Hello</title></block></value>
      </block>
    </category>
    <category name="Lists" colour="%{BKY_LISTS_HUE}">
      <block type="variables_set"><title name="VAR">list</title><value name="VALUE">
          <block type="lists_create_empty"  ></block>
      </value></block>
      <block type="variables_set"><title name="VAR">list</title><value name="VALUE">
        <block type="lists_create_with" inline="false"  >
          <mutation items="3"></mutation>
        </block>
      </value></block>
      <block type="variables_set"><title name="VAR">list</title><value name="VALUE">
        <block type="lists_repeat" inline="true"  >
          <value name="NUM">
            <block type="math_number">
              <title name="NUM">5</title>
            </block>
          </value>
        </block>
      </value></block>
      <block type="lists_length" inline="false"  ></block>
      <block type="lists_isEmpty" inline="true"  ></block>
      <block type="lists_indexOf" inline="true"  >
        <title name="END">FIRST</title>
        <value name="VALUE">
          <block type="variables_get">
            <title name="VAR">list</title>
          </block>
        </value>
      </block>
      <block type="lists_getIndex" inline="true"  >
        <mutation statement="false" at="true"></mutation>
        <title name="MODE">GET</title>
        <title name="WHERE">FROM_START</title>
        <value name="VALUE">
          <block type="variables_get">
            <title name="VAR">list</title>
          </block>
        </value>
      </block>
      <block type="lists_setIndex" inline="true"  >
        <mutation at="true"></mutation>
        <title name="MODE">SET</title>
        <title name="WHERE">FROM_START</title>
        <value name="LIST">
          <block type="variables_get">
            <title name="VAR">list</title>
          </block>
        </value>
      </block>
      <block type="lists_getSublist" inline="true"  >
        <mutation at1="true" at2="true"></mutation>
        <title name="WHERE1">FROM_START</title>
        <title name="WHERE2">FROM_START</title>
        <value name="LIST">
          <block type="variables_get">
            <title name="VAR">list</title>
          </block>
        </value>
      </block>
    </category>
    <category name="Variables">
      <block type="variables_set" inline="false"  >
        <title name="VAR">item</title>
      </block>
      <block type="variables_get"  >
        <title name="VAR">item</title>
      </block>
    </category>
    <!--<category name="Procedures">
      <block type="procedures_defnoreturn"  >
        <mutation></mutation>
        <title name="NAME">do something</title>
      </block>
      <block type="procedures_defreturn" inline="false"  >
        <mutation></mutation>
        <title name="NAME">do something2</title>
      </block>
      <block type="procedures_ifreturn" inline="true"  >
        <mutation value="1"></mutation>
      </block>
      TODO - need to auto-add calls here??
    </category> -->
    <category name="Espruino" disable_if="smartibot">
      <block type="espruino_getTime"></block>
      <block type="espruino_pin"></block>
      <block type="espruino_watch">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">BTN1</title></block></value>
      </block>
      <block type="espruino_digitalWrite">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">LED1</title></block></value>
      </block>
      <block type="espruino_digitalPulse">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">LED1</title></block></value>
        <value name="VAL"><block type="logic_boolean"><title name="BOOL">TRUE</title></block></value>
        <value name="TIME"><block type="math_number"><title name="NUM">100</title></block></value>
      </block>
      <block type="espruino_digitalRead">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">BTN1</title></block></value>
      </block>
      <block type="espruino_analogWrite">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">A1</title></block></value>
      </block>
      <block type="espruino_analogRead">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">A0</title></block></value>
      </block>
      <block type="espruino_pinMode">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">D0</title></block></value>
      </block>
      <block type="espruino_code">
      </block>
      <block type="espruino_jsexpression">
      </block>
    </category>
    <category name="Hardware" disable_if="smartibot">
      <block type="hw_servoMove">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">B13</title></block></value>
        <value name="VAL"><block type="math_number"><title name="NUM">1</title></block></value>
      </block>
      <block type="hw_servoStop">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">B13</title></block></value>
      </block>
      <block type="hw_ultrasonic">
        <value name="TRIG"><block type="espruino_pin"><title name="PIN">B4</title></block></value>
        <value name="ECHO"><block type="espruino_pin"><title name="PIN">B3</title></block></value>
      </block>
    </category>
    <category name="Graphics" disable_if="smartibot">
      <block type="gfx_clear">
      </block>
      <block type="gfx_flip">
      </block>
      <block type="gfx_setFont">
        <value name="SIZE"><block type="math_number"><title name="NUM">2</title></block></value>
      </block>
      <block type="gfx_setColor">
      </block>
      <block type="gfx_setBgColor">
      </block>
      <block type="gfx_drawString">
        <value name="TEXT"><block type="text"><title name="TEXT">Hello</title></block></value>
        <value name="X"><block type="math_number"><title name="NUM">0</title></block></value>
        <value name="Y"><block type="math_number"><title name="NUM">0</title></block></value>
      </block>
      <block type="gfx_moveTo">
        <value name="X"><block type="math_number"><title name="NUM">0</title></block></value>
        <value name="Y"><block type="math_number"><title name="NUM">0</title></block></value>
      </block>
      <block type="gfx_lineTo">
        <value name="X"><block type="math_number"><title name="NUM">100</title></block></value>
        <value name="Y"><block type="math_number"><title name="NUM">100</title></block></value>
      </block>
      <block type="gfx_draw">
        <value name="X"><block type="math_number"><title name="NUM">20</title></block></value>
        <value name="Y"><block type="math_number"><title name="NUM">20</title></block></value>
        <value name="X2"><block type="math_number"><title name="NUM">40</title></block></value>
        <value name="Y2"><block type="math_number"><title name="NUM">40</title></block></value>
      </block>
      <block type="gfx_image">
        <value name="X"><block type="math_number"><title name="NUM">20</title></block></value>
        <value name="Y"><block type="math_number"><title name="NUM">20</title></block></value>
      </block>
    </category>
    <category name="Menus" disable_if="smartibot">
      <block type="menu_message">
        <value name="TEXT"><block type="text"><title name="TEXT">Hello</title></block></value>
      </block>
      <block type="menu_alert">
        <value name="TEXT"><block type="text"><title name="TEXT">Hello</title></block></value>
      </block>
      <block type="menu_prompt">
        <value name="TEXT"><block type="text"><title name="TEXT">Hello</title></block></value>
      </block>
    </category>
    <!-- Bangle.js -->
    <category name="Bangle.js" disable_if="smartibot">
      <block type="bangle_beep"></block>
      <block type="bangle_buzz"></block>
      <block type="bangle_turnon"></block>
      <block type="bangle_turnoff"></block>
      <block type="bangle_on"></block>
      <block type="bangle_result_bool"></block>
      <block type="bangle_result_number"></block>
    </category>
    <category name="Robot" enable_if="robot">
      <block type="robot_motor"></block>
      <block type="robot_led"></block>
      <block type="robot_ldr"></block>
    </category>
    <!-- Amperka's MotorShield -->
    <category name="Amperka Motor Shield" enable_if="motorshield">
      <block type="amperka_motorshield_motor"></block>
      <block type="amperka_motorshield_motor_dir"></block>
    </category>
    <!-- Nordic Thingy:52 -->
    <category name="Nordic Thingy:52" enable_if="nordic_thingy">
      <block type="thingy_sound_play"><value name="SAMPLERATE"><block type="math_number"><title name="NUM">4000</title></block></value></block>
      <block type="thingy_sound_record"><value name="LEN"><block type="math_number"><title name="NUM">1000</title></block></value></block>
      <block type="thingy_sensor_once"></block>
      <block type="thingy_sensor_many"></block>
      <block type="thingy_result"></block>
    </category>
   <category name="Smartibot" enable_if="smartibot">
      <block type="smartibot_motor">
        <value name="VAL"><block type="math_number"><title name="NUM">0.5</title></block></value>
      </block>
      <block type="smartibot_LED">
        <value name="LR"><block type="math_number"><title name="NUM">50</title></block></value>
        <value name="LG"><block type="math_number"><title name="NUM">50</title></block></value>
        <value name="LB"><block type="math_number"><title name="NUM">50</title></block></value>
        <value name="RR"><block type="math_number"><title name="NUM">50</title></block></value>
        <value name="RG"><block type="math_number"><title name="NUM">50</title></block></value>
        <value name="RB"><block type="math_number"><title name="NUM">50</title></block></value>
      </block>
      <block type="smartibot_LEDcol">
        <value name="BRIGHT"><block type="math_number"><title name="NUM">0.9</title></block></value>
      </block>
      <block type="smartibot_servo">
        <value name="VAL"><block type="math_number"><title name="NUM">50</title></block></value>
      </block>
      <block type="espruino_watch">
        <value name="PIN"><block type="espruino_pin"><title name="PIN">BTN1</title></block></value>
      </block>
    </category>

    <category name="Bluetooth" enable_if="bluetooth">
      <block type="ble_connected"></block>
      <block type="ble_disconnected"></block>

      <block type="ble_uart_write">
        <value name="VAL"><block type="text"><title name="TEXT">LED.toggle()</title></block></value>
        <value name="DEV"><block type="ble_dev_name"></block></value>
      </block>
      <block type="ble_advertise">
        <value name="VAL"><block type="text"><title name="TEXT">Hello</title></block></value>
      </block>
      <block type="ble_on_advertise"></block>

      <block type="ble_dev_name"></block>
      <block type="ble_dev_prefix"></block>
      <block type="ble_dev_address"></block>

      <block type="ble_characteristic"></block>
      <block type="ble_characteristic_dropdown"></block>

      <block type="ble_setchar">
        <value name="CHAR"><block type="ble_characteristic_dropdown"></block></value>
        <value name="DEV"><block type="ble_dev_name"></block></value>
      </block>
      <block type="ble_getchar">
        <value name="CHAR"><block type="ble_characteristic_dropdown"></block></value>
        <value name="DEV"><block type="ble_dev_name"></block></value>
      </block>
      <block type="ble_write">
        <value name="CHAR"><block type="ble_characteristic_dropdown"></block></value>
        <value name="VAL"><block type="math_number"><title name="NUM">50</title></block></value>
      </block>
      <block type="ble_onwritten">
        <value name="CHAR"><block type="ble_characteristic_dropdown"></block></value>
      </block>
      <block type="ble_value"></block>
    </category>
    <category name="Functions" custom="PROCEDURE"></category>
  </xml>

    <!-- Blockly initial code -->
<xml id="blocklyInitial" style="display: none">
  <block type="espruino_watch" inline="true"  ><title name="EDGE">rising</title><value name="PIN"><block type="espruino_pin"><title name="PIN">BTN1</title></block></value><statement name="DO"><block type="espruino_digitalWrite" inline="true"><value name="PIN"><block type="espruino_pin"><title name="PIN">LED1</title></block></value><value name="VAL"><block type="logic_boolean"><title name="BOOL">TRUE</title></block></value><next><block type="espruino_timeout" inline="true"><value name="SECONDS"><block type="math_number"><title name="NUM">1</title></block></value><statement name="DO"><block type="espruino_digitalWrite" inline="true"><value name="PIN"><block type="espruino_pin"><title name="PIN">LED1</title></block></value><value name="VAL"><block type="logic_boolean"><title name="BOOL">FALSE</title></block></value></block></statement></block></next></block></statement></block>
</xml>
<xml id="blocklyInitial_smartibot" style="display: none">

</xml>

  </body>
</html>
